package com.tianhui.consignortwofei.pattern.orderOprate;

import com.tianhui.consignortwofei.R;
import com.tianhui.consignortwofei.constant.OrderStatus;
import com.tianhui.consignortwofei.mvp.model.enty.OrderInfo;
import com.tianhui.consignortwofei.mvp.model.enty.OrderOperateInfo;
import com.tianhui.consignortwofei.pattern.orderOprate.impl.AdjustUnloadTimeOperate;
import com.tianhui.consignortwofei.pattern.orderOprate.impl.CancelConfirmOperate;
import com.tianhui.consignortwofei.pattern.orderOprate.impl.DeliveryConfirmOperate;
import com.tianhui.consignortwofei.pattern.orderOprate.impl.DispatchDetailOperate;
import com.tianhui.consignortwofei.pattern.orderOprate.impl.EvaluationOperate;
import com.tianhui.consignortwofei.pattern.orderOprate.impl.LoadingConfirmOperate;
import com.tianhui.consignortwofei.pattern.orderOprate.impl.RealTimeLocationOperate;
import com.tianhui.consignortwofei.pattern.orderOprate.impl.TerminateDispatchOperate;
import com.tianhui.consignortwofei.pattern.orderOprate.impl.VehicleTrajectoryOperate;
import com.tianhui.consignortwofei.pattern.orderOprate.impl.insure.ChangeDressOperate;

import java.util.ArrayList;
import java.util.List;

/**
 * @author fgs
 * @date 2020/8/30
 * @description
 **/
public class DispatchOperateList implements IOperateList {
    @Override
    public List<OrderOperateInfo> getTopOperateList(OrderInfo orderInfo) {
        List<OrderOperateInfo> list = new ArrayList<>();
        OrderOperateInfo operateInfo;

        operateInfo = new OrderOperateInfo();
        operateInfo.operate = "确认装车";
        operateInfo.orderInfo = orderInfo;
        operateInfo.operateImageId = R.mipmap.icon_adjust_weight;
        operateInfo.isEnable = orderInfo.istrans == 0;
        operateInfo.iOrderOperate = new LoadingConfirmOperate();
        list.add(operateInfo);

        operateInfo = new OrderOperateInfo();
        operateInfo.operate = "确认收货";
        operateInfo.operateImageId = R.mipmap.icon_receive_confirm;
        operateInfo.orderInfo = orderInfo;
        operateInfo.isEnable = orderInfo.isrecelve == 0;
        operateInfo.iOrderOperate = new DeliveryConfirmOperate();
        list.add(operateInfo);

        operateInfo = new OrderOperateInfo();
        operateInfo.operate = "卸车时间";
        operateInfo.orderInfo = orderInfo;
        operateInfo.operateImageId = R.mipmap.icon_order_detail;
//        operateInfo.iOrderOperate = new OrderDetailOperate();
        operateInfo.iOrderOperate = new AdjustUnloadTimeOperate();
        list.add(operateInfo);

        operateInfo = new OrderOperateInfo();
        operateInfo.operate = "调度明细";
        operateInfo.orderInfo = orderInfo;
        operateInfo.operateImageId = R.mipmap.icon_dispatch_detail;
        operateInfo.iOrderOperate = new DispatchDetailOperate();
        list.add(operateInfo);

        return list;
    }

    @Override
    public OrderOperateInfo getBottomCenterOperateInfo(OrderInfo orderInfo) {

        if (orderInfo.isrecelve == 1 || orderInfo.isstate == OrderStatus.CANCELED || orderInfo.isstate == OrderStatus.TO_VOID || orderInfo.isstate == OrderStatus.TERMINATION) {
            if (orderInfo.isevaluate != 1) {
                OrderOperateInfo operateInfo = new OrderOperateInfo();
                operateInfo.operateImageId = R.mipmap.icon_operate_center;
                operateInfo.iOrderOperate = new EvaluationOperate();
                operateInfo.orderInfo = orderInfo;
                return operateInfo;
            }
        }
        return null;
    }

    @Override
    public OrderOperateInfo getTopCenterOperateInfo(OrderInfo orderInfo) {
        if (orderInfo != null && orderInfo.isstate == OrderStatus.CANCELING) {
            OrderOperateInfo operateInfo = new OrderOperateInfo();
            operateInfo.operateImageId = R.drawable.bg_cancel_confirm;
            operateInfo.iOrderOperate = new CancelConfirmOperate();
            operateInfo.orderInfo = orderInfo;
            operateInfo.operate = "确认取消";
            return operateInfo;
        } else {
            return null;
        }
    }

    @Override
    public List<OrderOperateInfo> getBottomOperateList(OrderInfo orderInfo) {
        List<OrderOperateInfo> list = new ArrayList<>();
        OrderOperateInfo operateInfo;

        operateInfo = new OrderOperateInfo();
        operateInfo.operate = "车辆轨迹";
        operateInfo.orderInfo = orderInfo;
        operateInfo.operateImageId = R.mipmap.icon_vehcle_trajectory;
        operateInfo.iOrderOperate = new VehicleTrajectoryOperate();
        list.add(operateInfo);

        operateInfo = new OrderOperateInfo();
        operateInfo.operate = "实时定位";
        operateInfo.orderInfo = orderInfo;
        operateInfo.operateImageId = R.mipmap.icon_vehicle_location;
        operateInfo.iOrderOperate = new RealTimeLocationOperate();
        list.add(operateInfo);

        operateInfo = new OrderOperateInfo();

        //修改地址
        String operate = "修改地址";
        ChangeDressOperate iOrderOperate = new ChangeDressOperate();
        operateInfo.orderInfo = orderInfo;
        operateInfo.isEnable = true;

        //状态>3且投保
//        String operate = "保单明细";
//        IOrderOperate iOrderOperate = new InsureDetailOperate();
//        if (orderInfo.isstate > 3 && orderInfo.Isinsure == 1) {
//            if (TextUtils.isEmpty(orderInfo.insurestate)) {
//                operate = "保单试算";
//                iOrderOperate = new InsureCalculateOperate();
//            } else if (!TextUtils.isEmpty(orderInfo.insurestate) && orderInfo.insurestate.equals("0")) {
//                operate = "保单试算";
//                iOrderOperate = new InsureCalculateOperate();
//            } else if (!TextUtils.isEmpty(orderInfo.insurestate) && (orderInfo.insurestate.equals("1") || orderInfo.insurestate.equals("2"))) {
//                operate = "保单投保";
//                iOrderOperate = new InsurePolicyOperate();
//            }
//            operateInfo.orderInfo = orderInfo;
//            operateInfo.isEnable = true;
//        } else {
//            operateInfo.isEnable = false;
//        }
        operateInfo.operate = operate;

        operateInfo.operateImageId = R.mipmap.icon_insure_detail;
        operateInfo.iOrderOperate = iOrderOperate;
        list.add(operateInfo);

        operateInfo = new OrderOperateInfo();
        operateInfo.operate = "终止单据";
        operateInfo.orderInfo = orderInfo;
        operateInfo.operateImageId = R.mipmap.icon_order_terminate;
//        operateInfo.type = 1;
        operateInfo.iOrderOperate = new TerminateDispatchOperate();
        list.add(operateInfo);

        return list;
    }
}
